-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
40 lines (33 loc) · 840 Bytes
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <stdio.h>
#include <string.h>
int main()
{
int n, m, p;
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
scanf("%d ", &m);
char produtos[m][51];
double precos[m], total = 0;
for (int j = 0; j < m; j++)
{
scanf("%s %lf", produtos[j], &precos[j]);
}
scanf("%d", &p);
char produtosComprados[p][51];
int quantidades[p];
for (int j = 0; j < p; j++)
{
scanf("%s %d", produtosComprados[j], &quantidades[j]);
for (int k = 0; k < m; k++)
{
if (strcmp(produtosComprados[j], produtos[k]) == 0)
{
total += precos[k] * quantidades[j];
}
}
}
printf("R$ %.2lf\n", total);
}
return 0;
}